//
//  PasswordPayView.m
//  Logistics
//
//  Created by luojinrong11 on 2018/4/24.
//  Copyright © 2018年 com.Logistics. All rights reserved.
//

#import "PasswordPayView.h"

@implementation PasswordPayView
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)awakeFromNib{
    [super awakeFromNib];
    self.passwordView.delegate = self;
    [[YYKeyboardManager defaultManager]addObserver:self];
    
}
-(void)keyboardChangedWithTransition:(YYKeyboardTransition)transition{
    WEAKSELF
    CGRect kbRect = [[YYKeyboardManager defaultManager] convertRect:transition.toFrame toView:weakSelf];
    [UIView animateWithDuration:.3 animations:^{
        if ([YYKeyboardManager defaultManager].keyboardVisible) {
            weakSelf.alertView.centerY = kbRect.origin.y -145;
        }else{
            weakSelf.alertView.centerY = weakSelf.centerY;
        }
    }];
}
-(void)showInView:(UIView *)view FinshBlock:(PWFinshedBlock)finsh ForgetBlock:(ForgetBlock)forget {
    [view addSubview:self];
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(view);
    }];
    self.forgetBlock = forget ;
    self.finishBlock = finsh;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.passwordView becomeFirstResponder];
    });
}
-(void)setWordViewStyle:(XGPasswordViewStyle *)wordViewStyle {
    _wordViewStyle = wordViewStyle;
    self.titleLabel.text = wordViewStyle.title;
    self.middelLabel.text = wordViewStyle.middleContext;
    self.amountLabel.text = wordViewStyle.amountText;
    self.amountLeftLabel.text = wordViewStyle.amountLeftText;
}
- (IBAction)forgetPasswordAction:(id)sender {
    [self removeFromSuperview];
    if (self.forgetBlock!= nil) {
        self.forgetBlock();
    }
}


- (IBAction)closeAction:(id)sender {
    [self removeFromSuperview];
}

/**
 *  监听输入的改变
 */
- (void)passWordDidChange:(WCLPassWordView *)passWord{
    
}

/**
 *  监听输入的完成时
 */
- (void)passWordCompleteInput:(WCLPassWordView *)passWord{
    [self removeFromSuperview];
    if (self.finishBlock != nil) {
        self.finishBlock(passWord.textStore);
    }
}

/**
 *  监听开始输入
 */
- (void)passWordBeginInput:(WCLPassWordView *)passWord{

}



@end
